home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libssl0.9.8.postinst < prev    next >
Encoding:
Text File  |  2007-03-05  |  5.1 KB  |  181 lines

  1. #!/bin/bash
  2.  
  3. . /usr/share/debconf/confmodule
  4.  
  5. set -e
  6.  
  7. package_name()
  8. {
  9.     echo $(basename $0 .postinst)
  10. }
  11.  
  12. # element() is a helper function for file-rc:
  13. element() {
  14.     local element list IFS
  15.  
  16.     element="$1"
  17.  
  18.     [ "$2" = "in" ] && shift
  19.     list="$2"
  20.     [ "$list" = "-" ] && return 1
  21.     [ "$list" = "*" ] && return 0
  22.  
  23.     IFS=","
  24.     set -- $list
  25.     case $element in
  26.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  27.         return 0
  28.     esac
  29.     return 1
  30. }
  31.  
  32. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  33. # running in $runlevel:
  34. filerc() {
  35.     local runlevel basename
  36.     runlevel=$1
  37.     basename=$2
  38.     while read LINE
  39.     do
  40.     case $LINE in
  41.         \#*|"") continue
  42.     esac
  43.  
  44.     set -- $LINE
  45.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  46.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  47.  
  48.     if element "$runlevel" in "$START" || element "S" in "$START"
  49.     then
  50.         echo "/etc/init.d/$basename"
  51.         return 0
  52.     fi
  53.     done < /etc/runlevel.conf
  54.     echo ""
  55. }
  56.  
  57. if [ "$1" = "configure" ]
  58. then
  59.     if [ ! -z "$2" ]; then
  60.     if dpkg --compare-versions "$2" lt 0.9.8c-2; then
  61.         echo -n "Checking for services that may need to be restarted..."
  62.  
  63.         check="sendmail openssh-server"
  64.         check="$check apache2-common ssh-nonfree exim4"
  65.         check="$check apache-ssl libapache-mod-ssl openvpn spamassassin"
  66.         check="$check courier-imap-ssl courier-mta-ssl courier-pop-ssl"
  67.         check="$check postfix cyrus21-imapd cyrus21-pop3d"
  68.         check="$check postgresql-7.4 postgresql-8.0 postgresql-8.1"
  69.         check="$check racoon dovecot-common bind9"
  70.         check="$check ntp openntpd clamcour"
  71.         check="$check fetchmail ftpd-ssl slapd"
  72.         check="$check proftpd proftpd-ldap proftpd-mysql proftpd-pgsql"
  73.         check="$check partimage-server conserver-server tor"
  74.         # Only get the ones that are installed, and configured
  75.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  76.         # apache2 ships its init script in apache2-common, but the
  77.         # script is apache2
  78.         check=$(echo $check | sed 's/apache2-common/apache2/g')
  79.         # For mod-ssl apache has to be restarted
  80.         check=$(echo $check | sed 's/libapache-mod-ssl/apache/g')
  81.         # The name of proftpd-{ldap,mysql,pgsql} init script is
  82.         # same as "proftpd".
  83.         check=$(echo $check | sed 's/proftpd-.*/proftpd/g')
  84.             # dovecot-common ships its init script, but the
  85.         # script name is dovecot for dovecot-{imapd,pop3d}.
  86.         check=$(echo $check | sed 's/dovecot-common/dovecot/g')
  87.         # openssh-server's init script it called ssh
  88.         check=$(echo $check | sed 's/openssh-server/ssh/g')
  89.         echo "done."
  90.  
  91.         echo "Checking init scripts..."
  92.         for service in $check; do
  93.         if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  94.            idl=$(ls /etc/init.d/${service} 2> /dev/null | head -n 1)
  95.            if [ -n "$idl" ] && [ -x $idl ]; then
  96.             services="$service $services"
  97.            else
  98.             echo "WARNING: init script for $service not found."
  99.            fi
  100.         else
  101.             if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  102.  
  103.             idl=$(filerc $rl $service)
  104.             else
  105.             idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
  106.             fi
  107.             if [ -n "$idl" ] && [ -x $idl ]; then
  108.                 services="$service $services"
  109.             fi
  110.         fi
  111.         done
  112.         if [ -n "$services" ]; then
  113.         db_version 2.0
  114.  
  115.         db_reset libssl0.9.8/restart-services
  116.         db_set libssl0.9.8/restart-services "$services"
  117.         db_input critical libssl0.9.8/restart-services || true
  118.         db_go || true
  119.         db_get libssl0.9.8/restart-services
  120.         # Arghhh, close all the stupid debconf pipes
  121.         db_stop
  122.         
  123.         if [ "x$RET" != "x" ]
  124.         then
  125.             services=$RET
  126.             answer=yes
  127.         else
  128.             answer=no
  129.         fi
  130.         echo
  131.         if [ "$answer" = yes ] && [ "$services" != "" ]; then
  132.             echo "Restarting services possibly affected by the upgrade:"
  133.             failed=""
  134.             rl=$(runlevel | sed 's/.*\ //')
  135.             for service in $services; do
  136.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  137.                 idl="invoke-rc.d ${service}"
  138.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  139.                 idl=$(filerc $rl $service)
  140.             else
  141.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
  142.             fi
  143.  
  144.             echo -n "  $service: stopping..."
  145.             $idl stop > /dev/null 2>&1 || true
  146.             sleep 1
  147.             echo -n "starting..."
  148.             if $idl start > /dev/null 2>&1; then
  149.                 echo "done."
  150.             else
  151.                 echo "FAILED! ($?)"
  152.                 failed="$service $failed"
  153.             fi
  154.             done
  155.             echo
  156.             if [ -n "$failed" ]; then
  157.             # Ruh roh, George
  158.             echo "The following services failed to start: $failed"
  159.             echo
  160.             echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  161.             echo "If the service still fails to start, you may need to file a bug on"
  162.             echo "$(package_name) or the service involved."
  163.             else
  164.             echo "Services restarted successfully."
  165.             fi
  166.             echo
  167.         fi
  168.         else
  169.         echo "Nothing to restart."
  170.         fi
  171.     fi # end upgrading and $2 lt 0.9.8c-2
  172.     fi # Upgrading
  173. fi
  174.  
  175. # Automatically added by dh_makeshlibs
  176. if [ "$1" = "configure" ]; then
  177.     ldconfig
  178. fi
  179. # End automatically added section
  180.  
  181.